<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 对于数组类型同样可以这样做
        let arr = [1,2,3];
        let proxy = new Proxy(arr,{
            set(target,key,value){
                console.log('有人视图添加或修改数据');
                return Reflect.set(...arguments)
            },
            get(){
                console.log('有人视图读取数据');
                return Reflect.get(...arguments);
            }
        });
        proxy.push(1);//你会发现push方法走了两遍get后又走了两遍set
        console.log(proxy[2]);
    </script>
</body>
</html>